﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Webcar.Controls
{
    public partial class SelectByMonth : System.Web.UI.UserControl
    {
        public event EventHandler SearchClick;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack) return;
            this.tbStart.Text = DateTime.Now.AddMonths(-3).ToString("yyyy-MM");
            this.tbEnd.Text = DateTime.Now.ToString("yyyy-MM");

        }
        public string GetStartDate()
        {
            return this.tbStart.Text;
        }
        public string GetEndDate()
        {
            return this.tbEnd.Text;
        }
        public void SetError(string text)
        {
            this.lblError.Text = text;
        }
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            this.SetError("");

            if (this.GetStartDate() == "")
            {
                this.SetError("请选择开始时间。");
                return;
            }
            if (this.GetEndDate() == "")
            {
                this.SetError("请选择结束时间。");
                return;
            }

            if (SearchClick != null) SearchClick(sender, e);
        }
    }
}